package com.shop2cn.iapi.sellerpromotion.testcase;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.grouponmgr.parameter.SaveGrouponReq;
import com.shop2cn.iapi.sellerpromotion.parameter.ConflictProduct;
import com.shop2cn.iapi.sellerpromotion.parameter.CreatePromotionBean;
import com.shop2cn.iapi.sellerpromotion.parameter.GetConflictProductsBean;
import com.shop2cn.iapi.sellerpromotion.service.GetConflictProductsCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.Shop2cnGrouponCallService;
import com.ymttest.business.service.Shop2cnSellerPromotionCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.mongo.Shop2cnSellerPromotionInfoWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*获取冲突商品列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetConflictProducts{
	private static GetConflictProductsBean getconflictproductsBean;
	private static GetConflictProductsCall getconflictproductsCall;
	private static Integer mchId;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取冲突商品列表");
		try {
			mchId=GodmchManageCallService.CreateSellerMch();
		} catch (Exception e) {
		}
	}

	@Before
	public void caseUp() {
		getconflictproductsBean=new GetConflictProductsBean();
		getconflictproductsCall=new GetConflictProductsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getconflictproductsCall.getOpurl());
		
	}

	@After
	public void caseDown() {
		Logger.end();
		try {
			Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
		} catch (Exception e) {
//			e.printStackTrace();
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetConflictProducts_001() {
		Logger.start(true,"全场活动获取冲突列表返回成功,商品时间重叠有冲突数据");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			//全场冲突不返还data 只告知有冲突
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_002() {
		Logger.start(true,"指定活动返回冲突列表返回成功,商品时间重叠有冲突数据-活动时间1-3获取实际0-2");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			List<ConflictProduct> list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(productId)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+productId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_003() {
		Logger.start(true,"全场活动获取冲突列表返回成功,商品重叠时间不重叠无冲突数据");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("200", getconflictproductsCall.getString("code"), "验证code");
			//全场冲突不返还data 只告知有冲突
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_004() {
		Logger.start(true,"指定活动获取冲突列表返回成功,商品重叠时间不重叠无冲突数据");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("200", getconflictproductsCall.getString("code"), "验证code");
			//全场冲突不返还data 只告知有冲突
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_005() {
		Logger.start(true,"多个全场活动获取冲突列表返回成功,时间和其中一个重叠有冲突数据");
		try {
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			CreatePromotionBean createpromotionBean2 = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean2.setName("后一个活动");
			createpromotionBean2.setBegin(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean2.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean2);
			//和后一个活动冲突
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(5,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			//全场冲突不返还data 只告知有冲突
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
			Logger.verifyIsContains(createpromotionBean2.getName(), getconflictproductsCall.getString("message"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_006() {
		Logger.start(true,"指定活动获取冲突列表返回成功,时间重叠商品不重叠无冲突数据");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            AddAgentProductBean addAgentProductBean2 = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId2 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean2);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId2));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("200", getconflictproductsCall.getString("code"), "验证code");
			//全场冲突不返还data 只告知有冲突
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_007() {
		Logger.start(true,"当前全场活动调用结束接口已结束,无冲突数据");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Shop2cnSellerPromotionCallService.PromotionEnd(mchId, promotionId);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("200", getconflictproductsCall.getString("code"), "验证code");
			//全场冲突不返还data 只告知有冲突
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_008() {
		Logger.start(true,"当前指定活动调用结束接口已结束,无冲突数据");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			Shop2cnSellerPromotionCallService.PromotionEnd(mchId, promotionId);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("200", getconflictproductsCall.getString("code"), "验证code");
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_009() {
		Logger.start(true,"指定活动返回冲突列表返回成功,商品时间重叠有冲突数据-活动时间1-3获取实际2-4");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			List<ConflictProduct> list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(productId)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+productId);

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_010() {
		Logger.start(true,"指定活动返回冲突列表返回成功,商品时间重叠有冲突数据-活动时间1-3获取实际0-4");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			List<ConflictProduct> list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(productId)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+productId);

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_011() {
		Logger.start(true,"指定活动返回冲突列表返回成功,商品时间重叠有冲突数据-活动时间0-4获取实际1-3");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			List<ConflictProduct> list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(productId)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+productId);

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_012() {
		Logger.start(true,"指定活动返回冲突列表返回成功,商品时间重叠有冲突数据-跨越覆盖多个活动");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            //活动1 1-2
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setName("活动1");
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			  //活动2 3-4
			CreatePromotionBean createpromotionBean2 = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean2.setBegin(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean2.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean2.setName("活动2");
			createpromotionBean2.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean2);
			
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(5,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			List<ConflictProduct> list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(productId)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+productId);
			//如果有多个活动那都展示出来
//			Logger.verifyIsContains(createpromotionBean.getName(), getconflictproductsCall.getString("data"), "验证data活动冲突提示有活动1");
			Logger.verifyIsContains(createpromotionBean2.getName(), getconflictproductsCall.getString("data"), "验证data活动冲突提示有活动2");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_013() {
		Logger.start(true,"指定活动返回冲突列表返回成功,商品时间无重叠无冲突数据-活动时间0-1,4-5获取实际2-3");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            //活动1 1-2
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setName("活动1");
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			  //活动2 3-4
			CreatePromotionBean createpromotionBean2 = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean2.setBegin(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean2.setEnd(YMTDateUtil.getBeforeOrNextDay(5,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean2.setName("活动2");
			createpromotionBean2.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean2);
			
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("200", getconflictproductsCall.getString("code"), "验证code");
			Logger.verifyEquals("null", getconflictproductsCall.getString("data"), "验证data");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetConflictProducts_014() {
		Logger.start(true,"不输入sellerid失败");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
//			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("400", getconflictproductsCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetConflictProducts_015() {
		Logger.start(true,"不输入begin失败");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
//			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("400", getconflictproductsCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetConflictProducts_016() {
		Logger.start(true,"不输入end失败");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("400", getconflictproductsCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetConflictProducts_017() {
		Logger.start(true,"输入begin晚于end失败");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("500", getconflictproductsCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetConflictProducts_018() {
		Logger.start(true,"不输入productIdList,按全场算-冲突");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
//			getconflictproductsBean.setProductIdList(Arrays.asList(productId));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_019() {
		Logger.start(true,"指定活动返回冲突列表返回成功,部分商品冲突返回正确冲突商品");
		try {
			//获取冲突商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
            
        	AddAgentProductBean addAgentProductBean2 = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId2 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean2);
            
			CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			createpromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			createpromotionBean.setProductIdList(productIdList);
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
//			CreatePromotionBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
//			CreatePromotionBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(productId,productId2));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			List<ConflictProduct> list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(productId)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+productId);
			Logger.verifyEquals(0,list.stream().filter(cp->cp.getProductId().equals(productId2)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中不包含:"+productId2);

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetConflictProducts_020() {
		Logger.start(true,"指定活动获取冲突列表返回成功-时间冲突-bug");
		//Tc_CreatePromotion_048
		try {
			String p1 = TestDataManager.getRandomUUID().toString();
            String p2 = TestDataManager.getRandomUUID().toString();
            String p3 = TestDataManager.getRandomUUID().toString();
            String p4 = TestDataManager.getRandomUUID().toString();
            
            CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.setProductIdList(Arrays.asList(p1,p2));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
			
			CreatePromotionBean createpromotionBean2 = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean2.setProductIdList(Arrays.asList(p3,p4));
			Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean2);
			
			getconflictproductsBean.setBegin(YMTDateUtil.getBeforeOrNextDay(0,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			getconflictproductsBean.setSellerId(mchId);
			getconflictproductsBean.setProductIdList(Arrays.asList(p1,p2));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			List<ConflictProduct> list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(p1)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+p1);
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(p2)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+p2);

			getconflictproductsBean.setProductIdList(Arrays.asList(p3,p4));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			 list = getconflictproductsCall.getConflictProductList();
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(p3)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+p3);
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(p4)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+p4);

			getconflictproductsBean.setProductIdList(Arrays.asList(p1,p3));
			getconflictproductsCall.setData(getconflictproductsBean);
			getconflictproductsCall.callService();			
			Logger.verifyEquals("1001", getconflictproductsCall.getString("code"), "验证code");
			 list = getconflictproductsCall.getConflictProductList();
//			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(p1)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+p1);
			 //找到了一个冲突活动就返回了 所以只会找到一个 - 现在是从后往前找
			Logger.verifyEquals(1,list.stream().filter(cp->cp.getProductId().equals(p3)).map(m->m.getProductId()).collect(Collectors.toList()).size(),"验证返回冲突商品中包含:"+p3);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}